/*
 * Class.cpp
 *
 *  Created on: Aug 5, 2009
 *      Author: ramesh
 */

#include "Class.h"

using namespace SymphonyAST;


string Class::getName() {
	return name;
}
void Class::setName(const string& name) {
	this->name = name;
}

void Class::import(const string& toImport) {
	importeds.push_back(toImport);
	importIndex++;
}

int Class::getImportedId(const string& imported) {
	for (int i = 0; i < (int)importeds.size(); i++) {
		if (importeds[i] == imported) {
			return i;
		}
	}
	return -1;
}

void Class::addMethod(const string& name, Method* method) {
	methods[name] = method;
	methodsList.push_back(name);
}

Method* Class::getMethod(const string& name) {
	return methods[name];
}

int Class::getMethodId(const string& name) {
	for (int i = 0; i < (int)methodsList.size(); i++) {
		if (methodsList[i] == name) {
			return i;
		}
	}

	return -1;
}

map<string, Method*> Class::getMethods() {
	return methods;
}

vector<string> Class::getMethodsIds() {
	return methodsList;
}


void Class::addMember(string name, Variable* member) {
	if (members.find(name) != members.end()) {
		throw "Duplicate declaration of " + name;
	}

	members[name] = member;
	membersList.push_back(name);
}
